import{AddReturn} from '../../service/th/Return'
import{sendMq} from '../../service/th/Return'
import{myReturn} from '../../service/th/Return'
import{selectOrder} from '../../service/th/Return'

export default {
    namespaced:true,
    state:{
        returnDTO:[],
        snapshotList:[],
        orderSerial:"",
        pageInfo:{},
        orderId:0,
        orderSerial:''
    },
    mutations:{
       setReturnDTO(state,returnDTO){
          state.returnDTO=returnDTO
       },
       setSnapshotList(state,snapshotList){
           state.snapshotList=snapshotList
       },
       setOrderSerial(state,orderSerial){
           state.orderSerial=orderSerial
       },
       setPageInfo(state,pageInfo){
           state.pageInfo=pageInfo
       },
       setOrderId(state,orderId){
           state.orderId=orderId
       },
       setOrderSerial(state,serial){
          state.orderSerial=serial
       }
       
    },
    actions:{
        async add(context,ReturnTwoDTO){
             ReturnTwoDTO.orderSerial=context.state.orderSerial;
            // console.log(context.state.orderSerial);
            await AddReturn(ReturnTwoDTO);
         },
         async select(context,info){
            let response =await myReturn(info);
            var a=response.data;
            context.commit("setPageInfo",response);
          context.commit("setReturnDTO",a);
        },
        async send(context,ReturnMonDTO){
            await sendMq(ReturnMonDTO);
        },
        async getOrder(context,orderId){
            let response =await selectOrder(orderId);
            console.log(response)
            context.commit("setOrderSerial",response.orderSerial)
            context.commit("setSnapshotList",response.snapshotList);
        }
    }
}